
<include file="Public:js"/>
<div class="page-group">
    <div class="page page-current" data-page="index">

        <div class="content" data-distance="100" style="text-align: center">
            <div class="swiper-container" style="height: 10rem">
                <div class="swiper-wrapper" style="height: 10rem">
                    <volist name="dpic" id="v">
                        <div class="swiper-slide" onclick="window.location.href='{$v.url}'">
                            <img src="{$v.pic_path}" style="width: 100%;height: 100%" title="{$v.title}">
                        </div>
                    </volist>
                </div>
                <div class="swiper-pagination banner_role"></div>
                <style>
                    .banner_role{text-align: center!important;}
                    .swiper-container-horizontal>.swiper-pagination{bottom:0rem;}
                    .swiper-pagination-bullet{background: transparent;border:1px solid #fff;opacity: 1;width:0.35rem;height: 0.35rem;}
                    .swiper-pagination-bullet-active{background: #fff;}
                </style>
                <!-- <div class="banner_announce"><marquee width="150" scrolldelay="700" loop="3" direction="left">啦啦啦哈哈哈哈哈哈哈哈哈哈哈哈哈和</marquee></div> -->
            </div>
            <div class="bar">
                <div class="searchbar color_white" style="background:#fff;">
                    <div class="search-input">
                        <label class="icon icon-search" for="search"></label>
                        <input type="search" id='search' class="border_radius" onclick="window.location.href='{:U('Book/kind')}'" placeholder="搜索关键字，选择分类" style="background: #EFEFEF;"/>
                    </div>
                    <!--<a onclick="window.location.href='{:U('Book/kind')}'" class="head_top_menu color_white">-->
                        <!--<span class="icon icon-menu search-bar" style=""></span>-->
                    <!--</a>-->
                </div>
            </div>
            <div style="height: 10px;"></div>
            <div class="index_rec">
                <volist name="booklists" id="vo" key="k">
                    <div class="index_rec_item" style="background:#fff url('/wechat/img/home/bg{$k}.jpg') no-repeat;background-size:100% auto;">
                        <if condition="$k lt 4">
                            <br><br><br><br><br>
                        <else/>
                            <div class="index_rec_head">
                                <img src="/wechat/img/home/pic_jixiangwu0{$k%3*2+1}@2x.png" />
                                <p class="index_rec_title">{$vo.name}</p>
                                <img src="/wechat/img/home/pic_jixiangwu0{$k%3*2+2}@2x.png" />
                            </div>
                            <p class="index_rec_head_en">The classification of books</p>
                        </if>
                        <div class="index_rec_content">
                            <div style="width:{:count($vo['booklist'])*9.5+9.5}rem;">
                                <volist name="vo.booklist" id="v">
                                    <div class="index_book_item" >
                                        <!--<div class="book_rent_num">借阅量:{$v.dj}</div>-->
                                        <img class="item_book_fm" src="{$v.b_logo}" alt="" onclick=window.location.href="{$v.detail_url}">
                                        <div class="item_info">
                                            <!--<div class="item_info_rec">来自<span style="color:red;">新华书店</span>推荐</div>-->
                                            <div class="item_info_title">{$v.sm}</div>
                                            <div class="item_info_press">{$v.press|default=' '}</div>
                                            <div class="data_book" style="margin-top: 5px;">
                                                <p class="book_price color_price">¥{$v.dj}</p>
                                                <p class="book_comment color_comment">{$v.apprise_num}</p>
                                                <p class="book_fav color_comment">{$v.like_num}</p>
                                            </div>
                                            <div class="button_operation" style="text-align: center">
                                                <input  onclick="rentbook(1,{$v.book_id})"  type="button" value="我 要 借 阅" class="button_iwant_buy btn_radius" />
                                            </div>
                                        </div>
                                    </div>
                                </volist>
                                <div class="index_book_item look_more" >
                                    <a href="{:U("Book/blist")}?type={$vo.type_id}" external>
                                    <img src="/wechat/img/home/chakangengduo@2x.png" />
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </volist>
            </div>
        </div>
    </div>
</div>
<div class="prompt_bag" ontouchmove="touch_move(event,$(this))" ontouchend="touch_end(event,$(this))" ontouchstart="touch_start(event,$(this))">
    <a href="{:U('Bag/index')}"  external>
        <img src="/wechat/img/icon_shubao@2x.png"   />
        <span class="info">+1</span>
    </a>
</div>
<script src="__PUBLIC__/js/animate.js"></script>
<script>
    $.config = {
        autoInit: true,
    }
</script>
<script>
    $(function () {
        $(".swiper-container").swiper({
            autoplay: 1500,
            pagination: '.swiper-pagination',
            autoplayDisableOnInteraction : false
        });
    });

    function rentbook(type,id){
        $.post("{:U('Book/is_rentorbuy')}",{id:id,type:type},function(data){
            if(data>0){
                //已借阅过
                if(confirm('您已借阅过此书或已加入书包，是否再次加入书包？')){
                    joincart(type,id);
                }
            }else{
                joincart(type,id);
            }
        });

    }

    function joincart(type,id){
        $.ajax({
            type: "GET",
            url: "{:U('Book/joincart')}",
            data: {id:id,type:type},
            dataType: "json",
            success: function(data){
                var str="";
                if(type==0){
                    str="加入购物车";
                }else{
                    str="加入书包";
                }
                if(data==1){
                    $.alert("成功"+str);
                    bag_animation();
                }
            }
        });
    }

    function bag_animation(){
        $('.prompt_bag').removeClass('animation_circle');
        window.setTimeout(function(){
            $('.prompt_bag').addClass('animation_circle');
        },50);
    }
</script>
